package com.vancouver.knows.ui.activity.citydiscount;

import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.vancouver.knows.R;
import com.vancouver.knows.business.Constants;
import com.vancouver.knows.business.bean.DiscountInfo;
import com.vancouver.knows.ui.base.BaseActivity;
import com.vancouver.knows.ui.fragment.citydiscount.MapDiscountResultListView;
import java.util.List;

import butterknife.Bind;

/**
 * Created by chenxunlin01 on 2016/6/6.
 */
public class MapListActivity extends BaseActivity{

    @Bind(R.id.toolbar)
    public Toolbar toolbar;
    @Bind(R.id.toobarTitle)
    public TextView toobarTitle;
    @Bind(R.id.discountList)
    public MapDiscountResultListView mapDiscountResultListView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map_list);
        toolbar.setTitle("");
        setSupportActionBar(toolbar);
        toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.back));
        toobarTitle.setText(R.string.map_title);

        List<DiscountInfo> data = imContext.getBusinessModule().getCacheManager().getSelectMapDiscountList();
        mapDiscountResultListView.setDatas(data);
        mapDiscountResultListView.initLoadableView();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void subHandleMessage(Message msg) {
        switch (msg.what) {
            case Constants.BUSINESS_STATUS_CITYDISCOUNT_MAP_COMMENT_COUNT_CHANGE:
                mapDiscountResultListView.flush();
                break;
        }
    }
}
